import WXRealLogUtil from "./WXRealLogUtil"

export default class WXUtil {
    static retryCall(callback: Function, target, title: string = '提示', content: string = '资源加载失败,需要重试') {
        if (window['wx'] == null) {
            return callback.call(target)
        }
        WXRealLogUtil.info("资源重试弹窗")
        window['wx']?.showModal({
            title: title,
            content: content,
            confirmText: "确定",
            showCancel: false,
            success(res) {
                if (res.confirm) {
                    WXRealLogUtil.info("资源重试弹窗用户确定")
                    callback.call(target)
                } else if (res.cancel) {
                    WXRealLogUtil.info('资源重试弹窗用户取消')
                }
            }
        })
    }

    static showWXContact() {
        WXRealLogUtil.info("联系客服")
        window['wx']?.openCustomerServiceConversation({
            success: res => {
            }
        });
    }
}